import react from '@vitejs/plugin-react';
import UnoCSS from 'unocss/vite';
import ViteRestart from 'vite-plugin-restart';
import { createAutoPlugion } from './authApi';
import imagemin from 'vite-plugin-imagemin';
import inspect from 'vite-plugin-inspect';
import unoConfig from '../../unocss.config.ts';
import { viteMockServe } from 'vite-plugin-mock';
export const pluginsConfig = (isDev: boolean) => {
  return [
    react(),
    UnoCSS(unoConfig),
    createAutoPlugion(),
    viteMockServe({
      mockPath: 'mock',
      enable: isDev,
      watchFiles: true, // watch files in mockPath
    }),
    isDev &&
      ViteRestart({
        restart: ['my.config.[jt]s'],
      }),
    !isDev &&
      imagemin({
        gifsicle: { optimizationLevel: 7, interlaced: false },
        optipng: { optimizationLevel: 7 },
        mozjpeg: { quality: 20 },
        pngquant: { quality: [0.8, 0.9], speed: 4 },
        svgo: { plugins: [{ removeViewBox: false }, { cleanupIDs: false }] },
        webp: {},
      }),
    isDev && inspect(),
  ];
};
